<template>
  <div class="newslist">
    <van-card
      v-for="item in newslist"
      :key="item.id"
      :title="item.title"
      :thumb="item.img_url"
      @click="goDetail(item.id)"
    >
      <div slot="price">
        2020-08-04 09:51:51
      </div>
      <div slot="num">
        点击1次
      </div>
    </van-card>
  </div>
</template>
<script>
export default {
  data: () => ({
    newslist: []
  }),
  created() {
    this.getNewsList()
  },
  methods: {
    async getNewsList () {
      try {
        const { data: { message } } = await this.Api.getNewsList()
        // console.log(message)
        this.newslist = message
      } catch (error) {
        this.$Toast('请求新闻列表数据失败...' + error.message)
      }
    },
    goDetail(id) {
      this.$router.push('/home/newsinfo/' + id)
    }
  }
}
</script>
<style lang="less" scoped>
.newslist {
  .van-card__thumb {
    height: 58px;
  }
  .van-card__content  {
    min-height: 58px;
  }
  .van-card__price {
    color: red;
  }
  .van-card__num {
    color: #4e4e4e;
  }
}
</style>
